Using UNION in a query with PHP [migrated]
Posted
by
work
on Programmers
See other posts from Programmers
or by work
Published on 2011-06-25T04:26:13Z
Indexed on
2011/06/25
8:30 UTC
Read the original article
Hit count: 152
I have an SQL query which links 3 tables using UNION
:
$sql ="(SELECT Drive.DriveID,Ram.Memory from Drive,Ram where Drive.DriveID = Ram.RamID) UNION
(SELECT Drive.DriveID,External.Memory from Drive, External where Drive.DriveID = External.ExtID)";
Suppose I want to get Ram.Name as well. How do I do this? If I use Ram.Name in the first SELECT
statement it would not produce the correct result.
Any method for tackling this? I want to do it using UNION
.
© Programmers or respective owner